/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.g;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.text.TextUtils;
import com.qihoo.gamecenter.sdk.common.IDispatcherCallback;
import com.qihoo.gamecenter.sdk.login.plugin.h.d;
import com.qihoo.gamecenter.sdk.login.plugin.h.e;
import com.qihoo.gamecenter.sdk.login.plugin.h.f;
import org.json.JSONException;
import org.json.JSONObject;

public class i {
    private Handler a = new Handler();
    private Context b;
    private a c = null;
    private boolean d = false;
    private boolean e = false;
    private int f = 0;

    public i(Context paramContext, boolean paramBoolean1, boolean paramBoolean2, int paramInt) {
        this.b = paramContext;
        this.d = paramBoolean1;
        this.e = paramBoolean2;
        this.f = paramInt;
    }

    public void a(String paramString, a parama) {
        this.c = parama;
        new Thread(new Runnable(paramString) {
            public void run() {
                String str1 = com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(i.a(i.this), this.a, "q", f.f());
                e.a("Plugin.ModifyInfoGuidTask", new Object[] { "get account info url = " + str1 });
                String str2 = com.qihoo.gamecenter.sdk.login.plugin.d.a.a(i.a(i.this), str1);
                e.a("Plugin.ModifyInfoGuidTask", new Object[] { "get account info res = " + str2 });
                try {
                    JSONObject localJSONObject1 = new JSONObject(str2);
                    int i = localJSONObject1.optInt("errno", -1);
                    if (0 == i) {
                        JSONObject localJSONObject2 = localJSONObject1.optJSONObject("data");
                        if (localJSONObject2 != null) {
                            String str3 = "";
                            boolean bool1 = com.qihoo.gamecenter.sdk.login.plugin.accountBind.a.a.a(i.a(i.this));
                            boolean bool2 = com.qihoo.gamecenter.sdk.login.plugin.accountBind.a.a.a(i.a(i.this), d.d());
                            if ((!(bool1)) && (!(bool2)) && (i.a(i.this, 2))) {
                                int j = 0;
                                JSONObject localJSONObject3 = localJSONObject2.optJSONObject("secmobile");
                                if (localJSONObject3 != null) {
                                    String str5 = localJSONObject3.optString("number", null);
                                    if (!(TextUtils.isEmpty(str5)))
                                        j = 1;
                                }
                                if (j == 0)
                                    str3 = str3 + "bind_phone|";
                            }
                            if (i.a(i.this, 1)) {
                                String str4 = localJSONObject2.optString("nickname", null);
                                if ((TextUtils.isEmpty(str4)) || (str4.startsWith("360U")))
                                    str3 = str3 + "modify_nick|";
                            }
                            boolean bool3 = com.qihoo.gamecenter.sdk.login.plugin.profile.a.b(i.a(i.this), d.d());
                            boolean bool4 = com.qihoo.gamecenter.sdk.login.plugin.profile.a.a(i.a(i.this), d.d());
                            int k = localJSONObject2.optInt("head_flag", 0);
                            if ((!(bool3)) && (!(bool4)) && (i.a(i.this, 4)))
                                if (1 == k)
                                    str3 = str3 + "modify_head|";
                                else
                                    com.qihoo.gamecenter.sdk.login.plugin.profile.a.b(i.a(i.this), d.d(), true);
                            i.a(i.this, str3);
                            return;
                        }
                    }
                } catch (Exception localException) {
                    e.b("Plugin.ModifyInfoGuidTask", "", localException);
                }
                i.a(i.this, null);
            }
        }).start();
    }

    private void a(String paramString) {
        this.a.post(new Runnable(paramString) {
            public void run() {
                i.b(i.this, this.a);
            }
        });
    }

    private void b(String paramString) {
        if (!(TextUtils.isEmpty(paramString))) {
            if ((paramString.contains("modify_nick")) && (a())) {
                a(this.b);
                return;
            }
            if ((paramString.contains("bind_phone")) && (a())) {
                c(this.b);
                return;
            }
            if ((paramString.contains("modify_head")) && (a())) {
                b(this.b);
                return;
            }
        }
        a(null);
    }

    private void a(Context paramContext) {
        Intent localIntent = new Intent();
        localIntent.putExtra("function_code", 264);
        localIntent.putExtra("screen_orientation", this.d);
        localIntent.putExtra("login_bg_transparent", this.e);
        localIntent.putExtra("is_from_login", true);
        localIntent.putExtra("login_show_close_icon", false);
        localIntent.setClassName(paramContext.getPackageName(), "com.qihoo.gamecenter.sdk.activity.ContainerActivity");
        long l = com.qihoo.gamecenter.sdk.common.a.a(new IDispatcherCallback() {
            public void onFinished(String paramString) {
                e.a("Plugin.ModifyInfoGuidTask", new Object[] { "runModifyNickNameTask res: " + paramString });
                JSONObject localJSONObject = null;
                if (!(TextUtils.isEmpty(paramString)))
                    try {
                        localJSONObject = new JSONObject(paramString);
                        localJSONObject.put("modify_nick", 1);
                    } catch (Exception localException) {
                        e.b("Plugin.ModifyInfoGuidTask", "", localException);
                    }
                i.a(i.this, localJSONObject);
            }
        });
        localIntent.putExtra("callback_id", l);
        paramContext.startActivity(localIntent);
    }

    private void b(Context paramContext) {
        Intent localIntent = new Intent();
        localIntent.putExtra("function_code", 262);
        localIntent.putExtra("screen_orientation", this.d);
        localIntent.putExtra("login_bg_transparent", this.e);
        localIntent.putExtra("is_from_login", true);
        localIntent.setClassName(paramContext.getPackageName(), "com.qihoo.gamecenter.sdk.activity.ContainerActivity");
        long l = com.qihoo.gamecenter.sdk.common.a.a(new IDispatcherCallback() {
            public void onFinished(String paramString) {
                e.a("Plugin.ModifyInfoGuidTask", new Object[] { "runModifyHeadShotTask res: " + paramString });
                JSONObject localJSONObject = null;
                if (!(TextUtils.isEmpty(paramString)))
                    try {
                        localJSONObject = new JSONObject(paramString);
                        localJSONObject.put("modify_head", 1);
                    } catch (Exception localException) {
                        e.b("Plugin.ModifyInfoGuidTask", "", localException);
                    }
                i.a(i.this, localJSONObject);
            }
        });
        localIntent.putExtra("callback_id", l);
        paramContext.startActivity(localIntent);
    }

    private void c(Context paramContext) {
        Intent localIntent = new Intent();
        localIntent.putExtra("function_code", 261);
        localIntent.putExtra("screen_orientation", this.d);
        localIntent.putExtra("login_bg_transparent", this.e);
        localIntent.putExtra("is_from_login", true);
        localIntent.setClassName(paramContext.getPackageName(), "com.qihoo.gamecenter.sdk.activity.ContainerActivity");
        long l = com.qihoo.gamecenter.sdk.common.a.a(new IDispatcherCallback() {
            public void onFinished(String paramString) {
                e.a("Plugin.ModifyInfoGuidTask", new Object[] { "runBindPhoneNumberTask res = " + paramString });
                JSONObject localJSONObject = null;
                if (!(TextUtils.isEmpty(paramString)))
                    try {
                        localJSONObject = new JSONObject(paramString);
                        localJSONObject.put("bind_phone", 1);
                    } catch (JSONException localJSONException) {
                        e.b("Plugin.ModifyInfoGuidTask", "", localJSONException);
                    }
                i.a(i.this, localJSONObject);
            }
        });
        localIntent.putExtra("callback_id", l);
        paramContext.startActivity(localIntent);
    }

    private void a(JSONObject paramJSONObject) {
        if (null == this.c)
            return;
        this.a.post(new Runnable(paramJSONObject) {
            public void run() {
                i.b(i.this).a(this.a);
            }
        });
    }

    private boolean a(int paramInt) {
        return f.a(this.f, paramInt);
    }

    private boolean a() {
        if (this.c != null)
            return this.c.a();
        return true;
    }

    public static abstract interface a {
        public abstract boolean a();

        public abstract void a(JSONObject paramJSONObject);
    }
}